package com.lm.actuator.component;

import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.stereotype.Component;

@Component
public class CustomHealthIndicator implements HealthIndicator {
    @Override
    public Health health() {
        boolean serverUp = checkServer(); // 自定义检查逻辑
        if (serverUp) {
            return Health.up().withDetail("CustomService", "Available").build();
        }
        return Health.down().withDetail("CustomService", "Not Available").build();
    }

    private boolean checkServer() {
        // 模拟逻辑，可以是数据库/缓存/外部服务检查
        return true;
    }
}
